//
//  PathMy.swift
//  imprint
//
//  Created by 小柠檬🍋 on 2025/1/2.
//

import Foundation

var pathManager = PathManager()

class PathManager : ObservableObject{
    @Published var path: [Jump] = []
    
    //简单的跳转
    func jump(type: JumpType) {
        let jumpWithoutData = Jump(type: type)
        path.append(jumpWithoutData)
    }
    //复杂的跳转,如带参数的
    func jump(type: JumpType, data: Codable) {
        let jumpWithoutData = Jump(type: type, data: data)
        path.append(jumpWithoutData)
    }
    
    //复杂的跳转,如带参数的
    func jump(data : Jump) {
        path.append(data)
    }
    
    func back() {
        guard !path.isEmpty else { return }
        path.removeLast()
    }
}
